<file>misc/extensionUtils.js</file>
<file>misc/fileUtils.js</file>
<file>misc/gnomeSession.js</file>
- <file>misc/hash.js</file>
<file>misc/history.js</file>
<file>misc/jsParse.js</file>
<file>misc/loginManager.js</file>
+++ /dev/null
-// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-
-const Lang = imports.lang;
-const System = imports.system;
-
-const Params = imports.misc.params;
-
-// This is an implementation of EcmaScript SameValue algorithm,
-// which returns true if two values are not observably distinguishable.
-// It was taken from http://wiki.ecmascript.org/doku.php?id=harmony:egal
-//
-// In the future, we may want to use the 'is' operator instead.
-function _sameValue(x, y) {
- if (x === y) {
- // 0 === -0, but they are not identical
- return x !== 0 || 1 / x === 1 / y;
- }
-
- // NaN !== NaN, but they are identical.
- // NaNs are the only non-reflexive value, i.e., if x !== x,
- // then x is a NaN.
- // isNaN is broken: it converts its argument to number, so
- // isNaN("foo") => true
- return x !== x && y !== y;
-}
-
-const _hashers = {
- object: function(o) { return o ? System.addressOf(o) : 'null'; },
- function: function(f) { return System.addressOf(f); },
- string: function(s) { return s; },
- number: function(n) { return String(n); },
- undefined: function() { return 'undefined'; },
-};
-
-/* Map is meant to be similar in usage to ES6 Map, which is
- described at http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets,
- without requiring more than ES5 + Gjs extensions.
-
- Known differences from other implementations:
- Polyfills around the web usually implement HashMaps for
- primitive values and reversed WeakMaps for object keys,
- but we want real maps with real O(1) semantics in all cases,
- and the easiest way is to have different hashers for different
- types.
-
- Known differences from the ES6 specification:
- - Map is a Lang.Class, not a ES6 class, so inheritance,
- prototype, sealing, etc. work differently.
- - items(), keys() and values() don't return iterators,
- they return actual arrays, so they incur a full copy everytime
- they're called, and they don't see changes if you mutate
- the table while iterating
- (admittedly, the ES6 spec is a bit unclear on this, and
- the reference code would just blow up)
-*/
-const Map = new Lang.Class({
- Name: 'Map',
-
- _init: function(iterable) {
- this._pool = { };
- this._size = 0;
-
- if (iterable) {
- for (let i = 0; i < iterable.length; i++) {
- let [key, value] = iterable[i];
- this.set(key, value);
- }
- }
- },
-
- _hashKey: function(key) {
- let type = typeof(key);
- return type + ':' + _hashers[type](key);
- },
-
- _internalGet: function(key) {
- let hash = this._hashKey(key);
- let node = this._pool[hash];
-
- if (node && _sameValue(node.key, key))
- return [true, node.value];
- else
- return [false, null];
- },
-
- get: function(key) {
- return this._internalGet(key)[1];
- },
-
- has: function(key) {
- return this._internalGet(key)[0];
- },
-
- set: function(key, value) {
- let hash = this._hashKey(key);
- let node = this._pool[hash];
-
- if (node) {
- node.key = key;
- node.value = value;
- } else {
- this._pool[hash] = { key: key, value: value };
- this._size++;
- }
- },
-
- delete: function(key) {
- let hash = this._hashKey(key);
- let node = this._pool[hash];
-
- if (node && _sameValue(node.key, key)) {
- delete this._pool[hash];
- this._size--;
- return [node.key, node.value];
- } else {
- return [null, null];
- }
- },
-
- keys: function() {
- let pool = this._pool;
- return Object.getOwnPropertyNames(pool).map(function(hash) {
- return pool[hash].key;
- });
- },
-
- values: function() {
- let pool = this._pool;
- return Object.getOwnPropertyNames(pool).map(function(hash) {
- return pool[hash].value;
- });
- },
-
- items: function() {
- let pool = this._pool;
- return Object.getOwnPropertyNames(pool).map(function(hash) {
- return [pool[hash].key, pool[hash].value];
- });
- },
-
- size: function() {
- return this._size;
- },
-});
const CtrlAltTab = imports.ui.ctrlAltTab;
const GnomeSession = imports.misc.gnomeSession;
const GrabHelper = imports.ui.grabHelper;
-const Hash = imports.misc.hash;
const Lightbox = imports.ui.lightbox;
const Main = imports.ui.main;
const PointerWatcher = imports.ui.pointerWatcher;
Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._expandActiveNotification));
- this._sources = new Hash.Map();
+ this._sources = new Map();
this._chatSummaryItemsCount = 0;
this._trayDwellTimeoutId = 0;
},
_updateNoMessagesLabel: function() {
- this._noMessages.visible = this._sources.size() == 0;
+ this._noMessages.visible = this._sources.size == 0;
},
_sessionUpdated: function() {
},
_removeSource: function(source) {
- let [, obj] = this._sources.delete(source);
+ let obj = this._sources.get(source);
+ this._sources.delete(source);
let summaryItem = obj.summaryItem;
if (source.isChat)
},
getSources: function() {
- return this._sources.keys();
+ return [k for (k of this._sources.keys())];
},
_onSourceEnableChanged: function(policy, source) {
const Background = imports.ui.background;
const GnomeSession = imports.misc.gnomeSession;
-const Hash = imports.misc.hash;
const Layout = imports.ui.layout;
const OVirt = imports.gdm.oVirt;
const LoginManager = imports.misc.loginManager;
this.actor.add(this._musicBin);
this.actor.add(this._scrollView, { x_fill: true, x_align: St.Align.START });
- this._sources = new Hash.Map();
+ this._sources = new Map();
Main.messageTray.getSources().forEach(Lang.bind(this, function(source) {
this._sourceAdded(Main.messageTray, source, true);
}));
this._sourceAddedId = 0;
}
- let items = this._sources.items();
- for (let i = 0; i < items.length; i++) {
- let [source, obj] = items[i];
+ let items = this._sources.entries();
+ for (let [source, obj] of items) {
this._removeSource(source, obj);
}
const Shell = imports.gi.Shell;
const Signals = imports.signals;
-const Hash = imports.misc.hash;
const Main = imports.ui.main;
const ScreencastIface = '<node> \
Gio.DBus.session.own_name('org.gnome.Shell.Screencast', Gio.BusNameOwnerFlags.REPLACE, null, null);
- this._recorders = new Hash.Map();
+ this._recorders = new Map();
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
},
get isRecording() {
- return this._recorders.size() > 0;
+ return this._recorders.size > 0;
},
_ensureRecorderForSender: function(sender) {
if (Main.sessionMode.allowScreencast)
return;
- for (let sender in this._recorders.keys())
- this._recorders.delete(sender);
+ this._recorders.clear();
this.emit('updated');
},
const ExtensionSystem = imports.ui.extensionSystem;
const ExtensionDownloader = imports.ui.extensionDownloader;
const ExtensionUtils = imports.misc.extensionUtils;
-const Hash = imports.misc.hash;
const Main = imports.ui.main;
const Screenshot = imports.ui.screenshot;
const ViewSelector = imports.ui.viewSelector;
this._extensionsService = new GnomeShellExtensions();
this._screenshotService = new Screenshot.ScreenshotService();
- this._grabbedAccelerators = new Hash.Map();
- this._grabbers = new Hash.Map();
+ this._grabbedAccelerators = new Map();
+ this._grabbers = new Map();
global.display.connect('accelerator-activated', Lang.bind(this,
function(display, action, deviceid, timestamp) {
},
_onGrabberBusNameVanished: function(connection, name) {
- let grabs = this._grabbedAccelerators.items();
- for (let i = 0; i < grabs.length; i++) {
- let [action, sender] = grabs[i];
+ let grabs = this._grabbedAccelerators.entries();
+ for (let [action, sender] of grabs) {
if (sender == name)
this._ungrabAccelerator(action);
}
const Signals = imports.signals;
const St = imports.gi.St;
-const Hash = imports.misc.hash;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
_init: function(client) {
this._client = client;
- this._connectionItems = new Hash.Map();
+ this._connectionItems = new Map();
this._connections = [];
this._labelSection = new PopupMenu.PopupMenuSection();
},
_sync: function() {
- let nItems = this._connectionItems.size();
+ let nItems = this._connectionItems.size;
this._switchSection.actor.visible = (nItems > 1);
this._labelSection.actor.visible = (nItems == 1);
_getStatus: function() {
let values = this._connectionItems.values();
- for (let i = 0; i < values.length; i++) {
- let item = values[i];
+ for (let item of values) {
if (item.isActive())
return item.getName();
}
},
_sync: function() {
- let nItems = this._connectionItems.size();
+ let nItems = this._connectionItems.size;
this._autoConnectItem.actor.visible = (nItems == 0);
this.parent();
},
},
_sync: function() {
- let nItems = this._connectionItems.size();
+ let nItems = this._connectionItems.size;
this.item.actor.visible = (nItems > 0);
this.parent();
},
},
setActiveConnections: function(vpnConnections) {
- this._connectionItems.values().forEach(function(item) {
+ let connections = this._connectionItems.values();
+ for (let item of connections) {
item.setActiveConnection(null);
- });
+ }
vpnConnections.forEach(Lang.bind(this, function(a) {
let item = this._connectionItems.get(a._connection.get_uuid());
item.setActiveConnection(a);
getIndicatorIcon: function() {
let items = this._connectionItems.values();
- for (let i = 0; i < items.length; i++) {
- let item = items[i];
+ for (let item of items) {
let icon = item.getIndicatorIcon();
if (icon)
return icon;